package model;

import java.sql.ResultSet;
import java.sql.SQLException;

public class User {
	protected int uid = 0;
	protected String username = null;
	protected String email = null;
	protected String password = null;
	protected int groupid = 0;
	
	public int getUid() {
		return uid;
	}
	public void setUid(int uid) {
		this.uid = uid;
	}
	
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	
	public String getPassword() {
		return password;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public int getGroupId(){
		return this.groupid;
	}
	
	public void setGroupId(int id){
		this.groupid = id;
	}
	
	public static User fromDatabase(ResultSet rs) {
		User u = new User();
		
		try{
			u.setUid(rs.getInt(1));
			u.setUsername(rs.getString(2));
			u.setEmail(rs.getString(3));
			u.setPassword(rs.getString(4));
			u.setGroupId(rs.getInt(5));
		}catch(SQLException e){
			e.printStackTrace();
		}
		
		return u;
	}
}
